<template>
	<view class="step-body">
		<view class="purchase-module">
			<view class="purchase-title">
				招标基本信息
			</view>
			<view class="purchase-content">
				<view class="content-box">
					<view class="cbox-1">
						代理机构采购编号
					</view>
					<view class="cbox-2">
						{{purCode}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						代理机构
					</view>
					<view class="cbox-2">
						{{agenciesId_dictText}}
					</view>
				</view>
				<view class="content-box" v-if="isFlage">
					<view class="cbox-1">
						中标供应商
					</view>
					<view class="cbox-2">
						{{supplierName}}
					</view>
				</view>
				<view class="content-box" v-if="isFlage">
					<view class="cbox-1">
						中标金额(万元)
					</view>
					<view class="cbox-2">
						{{finalMoney}}
					</view>
				</view>

				<view class="content-box" v-if="isFlage">
					<view class="cbox-1">
						中标供应商联系人
					</view>
					<view class="cbox-2">
						{{contacts}}
					</view>
				</view>
				<view class="content-box" v-if="isFlage">
					<view class="cbox-1">
						联系方式
					</view>
					<view class="cbox-2" >
						
						{{contactInformation}}
					</view>
				</view>
				<view class="content-box" v-if="isFlage">
					<view class="cbox-1">
						联系地址
					</view>
					<view class="cbox-2">
						{{address}}
					</view>
				</view>
				<view class="content-box" v-if="isFlage">
					<view class="cbox-1">
						报名开始时间
					</view>
					<view class="cbox-2">
						{{bmStartTime}}
					</view>
				</view>
				<view class="content-box" v-if="isFlage">
					<view class="cbox-1">
						报名时间截止
					</view>
					<view class="cbox-2">
						{{bmEndTime}}
					</view>
				</view>
				<view class="content-box" v-if="isFlage">
					<view class="cbox-1">
						开标时间
					</view>
					<view class="cbox-2">
						{{kbTime}}
					</view>
				</view>

			</view>
		</view>
		<view class="purchase-module" v-if="isFlage">
			<view class="purchase-title">
				招标供应商信息
			</view>
			<view class="purchase-content">
				<view class="rbox-1" v-for="item in supplierList " :key='item.id'>
					<view class="rbox-title">
						{{item.supplierId_dictText}}
					</view>
					<view class="rbox-item">
						<text>评分：</text>
						<text>{{item.score}}</text>
					</view>
					<view class="rbox-item">
						<text>报价(万元)：</text>
						<text>{{item.offer?item.offer.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','):'--'}}</text>
					</view>
				</view>
				<view class="rbox-3" style="line-height: 90rpx;text-align: center;" v-if="supplierList.length==0">
					暂无数据！
				</view>
			</view>
		</view>
		<view class="file-content">
			<view class="file-box">
				<view class="file-title">
					<view class="file-title-1">
						<view class="title">代理协议</view>
						<!-- <view class="waring">(预算金额≥20万)</view> -->
					</view>
					<view class="file-title-2" data-key='1' @click="change">
						<text class="number">{{DLXYList.length}}</text>
						<text class="lg text-black " :class="[key.join(',').indexOf('1')>-1?'cuIcon-fold':'cuIcon-unfold']" style="font-size: 32rpx;"></text>
					</view>
				</view>
				<view class="file-body" v-if="key.join(',').indexOf('1')>-1">
					<view class="file-item" v-for="item in DLXYList" :key='item.id'>
						<view class="file-item-box">
							<view class="box-image">
								<!-- <image src="../../static/Wicon/word.png" mode=""></image> -->
							</view>
							<view class="box-item-text">
								{{item.fileSourceName}}
							</view>
						</view>
						<view class="box-tsize">
							<text style="margin-right:10rpx;">{{item.fileSize?(item.fileSize/1024).toFixed(2):"--"}}kb</text>
							<text>|</text>
							<text style="margin-left:10rpx;">{{item.createTime}}</text>
						</view>
						<view class="box-item-option">
							<button class="cu-btn round line-blue download-btn" @click="downloadFile(item)">阅览下载</button>
						</view>

					</view>
					<view class="file-item file-item-none" v-if="DLXYList.length==0">
						暂无数据！
					</view>
				</view>
			</view>
			<view class="file-box">
				<view class="file-title">
					<view class="file-title-1">
						<view class="title">招标文件</view>
					</view>
					<view class="file-title-2" data-key='2' @click="change">
						<text class="number">{{ZBWJList.length}}</text>
						<text class="lg text-black " :class="[key.join(',').indexOf('2')>-1?'cuIcon-fold':'cuIcon-unfold']" style="font-size: 32rpx;"></text>
					</view>
				</view>
				<view class="file-body" v-if="key.join(',').indexOf('2')>-1">
					<view class="file-item" v-for="item in ZBWJList" :key='item.id'>
						<view class="file-item-box">
							<view class="box-image">
								<!-- <image src="../../static/Wicon/word.png" mode=""></image> -->
							</view>
							<view class="box-item-text">
								{{item.fileSourceName}}
							</view>
						</view>
						<view class="box-tsize">
							<text style="margin-right:10rpx;">{{item.fileSize?(item.fileSize/1024).toFixed(2):"--"}}kb</text>
							<text>|</text>
							<text style="margin-left:10rpx;">{{item.createTime}}</text>
						</view>
						<view class="box-item-option">
							<button class="cu-btn round line-blue download-btn" @click="downloadFile(item)">阅览下载</button>
						</view>

					</view>
					<view class="file-item file-item-none" v-if="ZBWJList.length==0">
						暂无数据！
					</view>

				</view>
			</view>
			<view class="file-box">
				<view class="file-title">
					<view class="file-title-1">
						<view class="title">招标公告</view>
						 </view> 
						 <view class="file-title-2" data-key='8' @click="change">
								<text class="number">{{ZBGGList.length}}</text>
								<text class="lg text-black " :class="[key.join(',').indexOf('8')>-1?'cuIcon-fold':'cuIcon-unfold']" style="font-size: 32rpx;"></text>
						</view>
					</view>
					<view class="file-body" v-if="key.join(',').indexOf('8')>-1">
						<view class="file-item" v-for="item in ZBGGList" :key='item.id'>
							<view class="file-item-box">
								<view class="box-image">
									<!-- <image src="../../static/Wicon/word.png" mode=""></image> -->
								</view>
								<view class="box-item-text">
									{{item.fileSourceName}}
								</view>
							</view>
							<view class="box-tsize">
								<text style="margin-right:10rpx;">{{item.fileSize?(item.fileSize/1024).toFixed(2):"--"}}kb</text>
								<text>|</text>
								<text style="margin-left:10rpx;">{{item.createTime}}</text>
							</view>
							<view class="box-item-option">
								<button class="cu-btn round line-blue download-btn" @click="downloadFile(item)">阅览下载</button>
							</view>
			
			
						</view>
						<view class="file-item file-item-none " v-if="ZBGGList.length==0">
							暂无数据！
						</view>
					</view>
				</view>
			<view class="file-box">
				<view class="file-title">
					<view class="file-title-1">
						<view class="title">技术参数对比表</view>
						<!-- <view class="waring">(预算金额>=20万且采购方式为单一来源)</view> -->
					</view>
					<view class="file-title-2" data-key='3' @click="change">
						<text class="number">{{JSCSDZBList.length}}</text>
						<text class="lg text-black " :class="[key.join(',').indexOf('3')>-1?'cuIcon-fold':'cuIcon-unfold']" style="font-size: 32rpx;"></text>
					</view>
				</view>
				<view class="file-body" v-if="key.join(',').indexOf('3')>-1">
					<view class="file-item" v-for="item in JSCSDZBList" :key='item.id'>
						<view class="file-item-box">
							<view class="box-image">
								<!-- <image src="../../static/Wicon/word.png" mode=""></image> -->
							</view>
							<view class="box-item-text">
								{{item.fileSourceName}}
							</view>
						</view>
						<view class="box-tsize">
							<text style="margin-right:10rpx;">{{item.fileSize?(item.fileSize/1024).toFixed(2):"--"}}kb</text>
							<text>|</text>
							<text style="margin-left:10rpx;">{{item.createTime}}</text>
						</view>
						<view class="box-item-option">
							<button class="cu-btn round line-blue download-btn" @click="downloadFile(item)">阅览下载</button>
						</view>


					</view>
					<view class="file-item file-item-none" v-if="JSCSDZBList.length==0">
						暂无数据！
					</view>
				</view>
			</view>
			<view class="file-box">
				<view class="file-title">
					<view class="file-title-1">
						<view class="title">专家签到表</view>
						<!-- <view class="waring">(预算金额≥20万)</view> -->
					</view>
					<view class="file-title-2" data-key='4' @click="change">
						<text class="number">{{ZJQDBList.length}}</text>
						<text class="lg text-black " :class="[key.join(',').indexOf('4')>-1?'cuIcon-fold':'cuIcon-unfold']" style="font-size: 32rpx;"></text>
					</view>
				</view>
				<view class="file-body" v-if="key.join(',').indexOf('4')>-1">
					<view class="file-item" v-for="item in ZJQDBList" :key='item.id'>
						<view class="file-item-box">
							<view class="box-image">
								<!-- <image src="../../static/Wicon/word.png" mode=""></image> -->
							</view>
							<view class="box-item-text">
								{{item.fileSourceName}}
							</view>
						</view>
						<view class="box-tsize">
							<text style="margin-right:10rpx;">{{item.fileSize?(item.fileSize/1024).toFixed(2):"--"}}kb</text>
							<text>|</text>
							<text style="margin-left:10rpx;">{{item.createTime}}</text>
						</view>
						<view class="box-item-option">
							<button class="cu-btn round line-blue download-btn" @click="downloadFile(item)">阅览下载</button>
						</view>


					</view>
					<view class="file-item file-item-none" v-if="ZJQDBList.length==0">
						暂无数据！
					</view>
				</view>
			</view>
			<view class="file-box">
				<view class="file-title">
					<view class="file-title-1">
						<view class="title">专家评分表</view>
						<!-- <view class="waring">(预算金额≥20万)</view> -->
					</view>
					<view class="file-title-2" data-key='5' @click="change">
						<text class="number">{{ZJPFBList.length}}</text>
						<text class="lg text-black " :class="[key.join(',').indexOf('5')>-1?'cuIcon-fold':'cuIcon-unfold']" style="font-size: 32rpx;"></text>
					</view>
				</view>
				<view class="file-body" v-if="key.join(',').indexOf('5')>-1">
					<view class="file-item" v-for="item in ZJPFBList" :key='item.id'>
						<view class="file-item-box">
							<view class="box-image">
								<!-- <image src="../../static/Wicon/word.png" mode=""></image> -->
							</view>
							<view class="box-item-text">
								{{item.fileSourceName}}
							</view>
						</view>
						<view class="box-tsize">
							<text style="margin-right:10rpx;">{{item.fileSize?(item.fileSize/1024).toFixed(2):"--"}}kb</text>
							<text>|</text>
							<text style="margin-left:10rpx;">{{item.createTime}}</text>
						</view>
						<view class="box-item-option">
							<button class="cu-btn round line-blue download-btn" @click="downloadFile(item)">阅览下载</button>
						</view>


					</view>
					<view class="file-item file-item-none" v-if="ZJPFBList.length==0">
						暂无数据！
					</view>
				</view>
			</view>
			<view class="file-box">
				<view class="file-title">
					<view class="file-title-1">
						<view class="title">评标报告</view>
						 </view> <view class="file-title-2" data-key='6' @click="change">
								<text class="number">{{PBBGList.length}}</text>
								<text class="lg text-black " :class="[key.join(',').indexOf('6')>-1?'cuIcon-fold':'cuIcon-unfold']" style="font-size: 32rpx;"></text>
						</view>
					</view>
					<view class="file-body" v-if="key.join(',').indexOf('6')>-1">
						<view class="file-item" v-for="item in PBBGList" :key='item.id'>
							<view class="file-item-box">
								<view class="box-image">
									<!-- <image src="../../static/Wicon/word.png" mode=""></image> -->
								</view>
								<view class="box-item-text">
									{{item.fileSourceName}}
								</view>
							</view>
							<view class="box-tsize">
								<text style="margin-right:10rpx;">{{item.fileSize?(item.fileSize/1024).toFixed(2):"--"}}kb</text>
								<text>|</text>
								<text style="margin-left:10rpx;">{{item.createTime}}</text>
							</view>
							<view class="box-item-option">
								<button class="cu-btn round line-blue download-btn" @click="downloadFile(item)">阅览下载</button>
							</view>


						</view>
						<view class="file-item file-item-none " v-if="PBBGList.length==0">
							暂无数据！
						</view>
					</view>
				</view>
				<view class="file-box">
					<view class="file-title">
						<view class="file-title-1">
							<view class="title">开标一览表</view>
							 </view> <view class="file-title-2" data-key='7' @click="change">
									<text class="number">{{KBYLBList.length}}</text>
									<text class="lg text-black " :class="[key.join(',').indexOf('7')>-1?'cuIcon-fold':'cuIcon-unfold']" style="font-size: 32rpx;"></text>
							</view>
						</view>
						<view class="file-body" v-if="key.join(',').indexOf('7')>-1">
							<view class="file-item" v-for="item in KBYLBList" :key='item.id'>
								<view class="file-item-box">
									<view class="box-image">
										<!-- <image src="../../static/Wicon/word.png" mode=""></image> -->
									</view>
									<view class="box-item-text">
										{{item.fileSourceName}}
									</view>
								</view>
								<view class="box-tsize">
									<text style="margin-right:10rpx;">{{item.fileSize?(item.fileSize/1024).toFixed(2):"--"}}kb</text>
									<text>|</text>
									<text style="margin-left:10rpx;">{{item.createTime}}</text>
								</view>
								<view class="box-item-option">
									<button class="cu-btn round line-blue download-btn" @click="downloadFile(item)">阅览下载</button>
								</view>
				
				
							</view>
							<view class="file-item file-item-none " v-if="KBYLBList.length==0">
								暂无数据！
							</view>
						</view>
					</view>
					
			</view>

		</view>
</template>

<script>
	import {
		getSupplierList,
		getZBBaseInfor,
		getZBFileList
	} from '../../../api/service.js'
	export default {
		props: ['cgId', 'status', 'id','type'],
		data() {
			return {
				supplierList: [],
				DLXYList: [],
				PBBGList: [],
				ZJPFBList: [],
				ZJQDBList: [],
				JSCSDZBList: [],
				ZBWJList: [],
				ZBGGList:[],
				KBYLBList:[],
				key: ['1'],
				address: '',
				agenciesId_dictText: '',
				bmEndTime: '',
				bmStartTime: '',
				contactInformation: '',
				contacts: '',
				finalMoney: '',
				kbTime: '',
				purCode: '',
				supplierName: '',
				isFlage2:false

			}
		},
		computed:{
			isFlage(){
				console.log(this.type)
				return this.type=='DLCG'?false:true
			}
		},
		created() {
			if(this.type=='DLCG_KB'){
				this.querySupplierList();
			}
			
			this.queryZBBaseInfor();
			this.queryZBFileList()
		},
		methods: {
			queryZBFileList() {
				getZBFileList({
					id: this.id
				}).then(res => {
					if (res.success) {
						if (res.result.length >= 0) {
							this.DLXYList = res.result.filter(item => {
								return item.usedType == 'FILE_USEDTYPE_DLCG_DLXY'
							})
							this.ZBWJList = res.result.filter(item => {
								return item.usedType == 'FILE_USEDTYPE_DLCG_ZBWJ'
							})

							this.JSCSDZBList = res.result.filter(item => {
								return item.usedType == 'FILE_USEDTYPE_DLCG_JSCSDZB'
							})
					        this.ZJQDBList=res.result.filter(item=>{
								return item.usedType=='FILE_USEDTYPE_DLCG_ZJQDB'
							})	
						this.ZJPFBList=res.result.filter(item=>{
							return item.usedType=='FILE_USEDTYPE_DLCG_ZJPFB'
						})
								
								this.PBBGList=res.result.filter(item=>{
									return item.usedType=='FILE_USEDTYPE_DLCG_PBBG'
								})
								
								this.ZBGGList=res.result.filter(item=>{
									return item.usedType=='FILE_USEDTYPE_DLCG_ZBGG'
								})
								this.KBYLBList=res.result.filter(item=>{
									return item.usedType=='FILE_USEDTYPE_DLCG_KBYLB'
								})
						}
					}
				})
			},
			// 供应商list
			querySupplierList() {
				getSupplierList({
					taskId: this.id
				}).then(res => {
					if (res.result && res.result.records.length > 0) {
						this.supplierList = res.result.records;
					}
				})
			},
			// 招标信息
			queryZBBaseInfor() {
				uni.showLoading({
				    title: '数据加载中'
				});
				getZBBaseInfor({
					id: this.id
				}).then(res => {
					uni.hideLoading()
					if (res.result) {
						this.address = res.result.address;
						this.agenciesId_dictText = res.result.agenciesId_dictText
						this.bmEndTime = res.result.bmEndTime;
						this.bmStartTime = res.result.bmStartTime;
						this.contactInformation = res.result.contactInformation;
						this.contacts = res.result.contacts;
						this.finalMoney = res.result.finalMoney;
						this.kbTime = res.result.kbTime;
						this.purCode = res.result.purCode;
						this.supplierName = res.result.supplierName
					}
				})
			},
			change(e) {
				console.log(e)
				var currentKey = e.currentTarget.dataset.key;
				var newData = [...this.key];
				if (this.key.join(',').indexOf(currentKey) > -1) {
					this.key = newData.filter(item => {
						return item != currentKey
					});
				} else {
					this.key.push(currentKey)
				}
			},
			downloadFile(record) {
				window.open(`${this.download}sys/file/view/${record.id}`, "_blank");

			},
		}
	}
</script>

<style lang="scss">
	@import "../../../colorui/purchase.scss";

	.file-item-none {
		line-height: 60rpx;
		text-align: center;
	}

	.box-item-option {
		display: flex;
		// align-items: flex-end;
		flex-direction: row;
		justify-content: flex-end;
		text-align: right;
		padding: 10rpx 8rpx;
	}

	.download-btn {
		height: 48rpx !important;
		padding: 0 20rpx !important;
		// display: inline-block;
	}

	.file-item {
		display: flex;
		flex-direction: column;
		justify-content: center;
		margin-bottom: 10rpx;

		.file-item-box {

			display: flex;
			flex-direction: row;
			flex: 1;
			justify-content: flex-start;

			// align-items: center;
			.box-image {
				flex: 0;

				image {
					width: 48rpx;
					height: 48rpx;
				}
			}

			.box-item-text {
				flex: 1;
				padding-left: 26rpx;
			}
		}

		.box-tsize {
			padding-left: 74rpx;
			line-height: 36rpx;
			font-size: 22rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(153, 153, 153, 1);
			// line-height:32px;
		}
	}

	.file-content {
		background: #f5f5f5;
		display: flex;
		justify-content: center;
		flex-direction: column;

		.file-box {
			flex: 1;
			margin-bottom: 30rpx;
			background: #fff;
			min-height: 124rpx;
			padding: 20rpx 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			// align-items: center;

			&:first-child {
				margin-top: 20rpx;
			}
		}


	}

	.file-title {
		flex: 1;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		margin-bottom: 20rpx;
		border-bottom: 2rpx solid #F7F4F4;
		padding-bottom: 6rpx;

		.file-title-1 {
			flex: 4;
			text-align: left;

			.title {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: rgba(51, 51, 51, 1);
				line-height: 42rpx;
			}

			.waring {
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: rgba(250, 85, 60, 1);
				line-height: 34rpx;
			}
		}

		.file-title-2 {
			flex: 1;
			text-align: right;

		}
	}
</style>
